import * as apiService from '@/services/api';

/**
 * 获取正常提现列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawList = params => apiService.post(api.WITHDRAW_LIST, params);
/**
 * 获取异常提现列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawExceptionList = (params) => {
  let { riskType } = params;
  if (!_.isUndefined(riskType)) {
    if (_.isArray(riskType)) {
      riskType = riskType.join(',');
    }
    params.riskType = riskType;
  }
  return apiService.post(api.WITHDRAW_EXCEPTION_LIST, params);
};
/**
 * 获取异常提现列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawAuditList = params => apiService.post(api.WITHDRAW_AUDIT_LIST, params);
/**
 * 查询所有支持的提现银行列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawBankList = params => apiService.post(api.WITHDRAW_BANK_LIST, params);
/**
 * 提现退回审核
 * @param params
 * @returns {Promise<*>}
 *
 */
const updateWithdrawAuditStatus = params => apiService.post(api.WITHDRAW_AUDIT_UPDATE_STATUS, params);
/**
 * 处理正常提现
 * @param params
 * @returns {Promise<*>}
 *
 */
const updateWithdrawNormalStatus = params => apiService.post(api.WITHDRAW_NORMAL_UPDATE_STATUS, params);
/**
 * 处理正常提现
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawForceSuccess = params => apiService.post(api.WITHDRAW_FORCE_SUCCESS, params);

/**
 * 处理异常正常提现
 * @param params
 * @returns {Promise<*>}
 *
 */
const updateWithdrawStatus = params => apiService.post(api.WITHDRAW_UPDATE_STATUS, params);
/**
 * 申请退回
 * @param params
 * @returns {Promise<*>}
 *
 */
const returnWithdrawSave = params => apiService.post(api.WITHDRAW_RETURN, params);
/**
 * 查询所有提现退回申请人
 * /gl/withdraw/manage/list/return/creator
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawReturnCreator = params => apiService.post(api.WITHDRAW_RETURN_CREATOR, params);
/**
 * 查询所有提现退回审核人
 * /gl/withdraw/manage/list/return/approver
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawReturnApprover = params => apiService.post(api.WITHDRAW_RETURN_APPROVER, params);
/**
 * 获取正常提现详情
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawDetail = params => apiService.post(api.WITHDRAW_DETAIL, params);
/**
 * 查询所有第三方提现应用
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawMerchantList = params => apiService.post(api.WITHDRAW_MERCHANT_LIST, params);
/**
 * 获取提现的出款商户
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawShopList = params => apiService.post(api.WITHDRAW_SHOP_LIST, params);
/**
 * 获取提现的出款商户(新)
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawShopDetail = params => apiService.post(api.WITHDRAW_SHOP_LIST_DETAIL, params);
/**
 * 获取充值的入款商户
 * @param params
 * @returns {Promise<*>}
 *
 */
const getRechargeShopDetail = params => apiService.post(api.RECHARGE_SHOP_LIST_DETAIL, params);
/**
 * 获取提现配置
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawConfigs = params => apiService.post(api.WITHDRAW_CONFIGS, params);
/**
 * 更新提现配置
 * @param params
 * @returns {Promise<*>}
 *
 */
const updateWithdrawConfigs = params => apiService.post(api.WITHDRAW_CONFIGS_UPDATE, params);
/**
 * 获取提现的三方列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawEscrows = params => apiService.post(api.WITHDRAW_ESCROWS, params);
/**
 * 获取提现的三方详情
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawEscrowDetail = params => apiService.post(api.WITHDRAW_ESCROW_DETAIL, params);
/**
 * 编辑提现三方应用
 * @param params
 * @returns {Promise<*>}
 *
 */
const editWithdrawEscrow = (params) => {
  const {
    id, channelId, maxAmount, minAmount, merchantId, remark,
  } = params;
  if (_.isUndefined(id)) {
    return apiService.post(api.WITHDRAW_ESCROW_ADD, {
      channelId, maxAmount, minAmount, merchantId, remark,
    });
  }
  return apiService.post(api.WITHDRAW_ESCROW_EDIT, {
    id, channelId, maxAmount, minAmount, merchantId, remark,
  });
};
/**
 * 更新提现三方应用的状态
 * @param params
 * @returns {Promise<*>}
 *
 */
const updateWithdrawEscrowStatus = params => apiService.post(api.WITHDRAW_ESCROW_STATUS_UPDATE, params);
/**
 * 删除提现三方应用
 * @param params
 * @returns {Promise<*>}
 *
 */
const delWithdrawEscrow = params => apiService.post(api.WITHDRAW_ESCROW_DEL, params);

/**
 *  三方提现排序
 * */
const updateEcsrowsSort = (params) => {
  const { ids } = params;
  return apiService.post(api.WITHDRAW_ESCROWS_SORT, params);
};

/**
 * 导出三方手动出款记录报表
 * @param params
 * @returns {Promise<*>}
 *
 */
const exportAutoRecord = params => apiService.post(api.EXPORT_WITHDRAW_AUTO_RECORD, params);

/**
 * 提现通用设置
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawNormalSetting = params => apiService.post(api.WITHDRAW_NORMAL_SETTING, params);

/**
 * 提交提现通用设置
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawNormalSettingSave = params => apiService.post(api.WITHDRAW_NORMAL_SETTING_SAVE, params);
/**
* 获取提现拒绝理由通用设置列表
* @param params
* @returns {Promise<*>}
*
*/
const withdrawRefuseReasonList = params => apiService.get(api.WITHDRAW_REFUSE_REASONLIST, params);
/**
 * 保存提现拒绝理由通用设置
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawRefuseReasonSave = params => apiService.post(api.WITHDRAW_REFUSE_REASON_SAVE, params);
/**
 * VIP提现设置
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawVipConfig = params => apiService.post(api.WITHDRAW_VIP_CONFIG, params);


/**
 * 保存VIP提现设置
 * @param params
 * @returns {Promise<*>}
 *
 */
const updateWithdrawVipConfig = params => apiService.post(api.WITHDRAW_VIP_CONFIG_SAVE, params);

/**
 * 代理提现设置
 * @param params
 * @returns {Promise<*>}
 *
 */
const getWithdrawAgencyConfigs = params => apiService.post(api.WITHDRAW_AGENCY_CONFIG, params);

/**
 * 保存代理提现设置
 * @param params
 * @returns {Promise<*>}
 *
 */
const updateWithdrawAgencyConfigs = params => apiService.post(api.WITHDRAW_AGENCY_CONFIG_SAVE, params);
/**
 * 提现分单时间区间设置
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawTimingConfig = params => apiService.post(api.WITHDRAW_TIMING_CONFIG, params);
/**
 * 获取分单时间区间配置的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawTimingGet = params => apiService.post(api.WITHDRAW_TIMING_GET, params);
/**
 * 获取提现分单条件列表的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawConditionList = params => apiService.post(api.WITHDRAW_CONDITION_LIST, params);
/**
 * 删除提现分单条件列表的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawConditionDelete = params => apiService.post(api.WITHDRAW_CONDITION_DELETE, params);
/**
 * 保存提现分单条件设置的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawConditionSave = params => apiService.post(api.WITHDRAW_CONDITION_SAVE, params);
/**
 * 编辑提现分单条件设置的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawConditionEdit = params => apiService.post(api.WITHDRAW_CONDITION_EDIT, params);
/**
 * 保存自动出款条件设置的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawAutoSave = params => apiService.post(api.WITHDRAW_AUTO_SAVE, params);
/**
 * 获取自动出款条件列表的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawAutoList = params => apiService.post(api.WITHDRAW_AUTO_LIST, params);
/**
 * 编辑自动出款条件列表的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawAutoUpdate = params => apiService.post(api.WITHDRAW_AUTO_UPDATE, params);
/**
 * 删除自动出款条件列表的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawAutoDelete = params => apiService.post(api.WITHDRAW_AUTO_DELETE, params);
/**
 * 查看层级设置的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawLevelList = params => apiService.post(api.WITHDRAW_LEVEL_LIST, params);
/**
 * 查询分单账户列表的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawAccountList = params => apiService.post(api.WITHDRAW_ACCOUNT_LIST, params);
/**
 * 用户名校验：找出不存在的用户名
 * @param params
 * @returns {Promise<*>}
 *
 */
const validateUser = params => apiService.post(api.VALIDATE_USER, params);
/**
 * 批量添加分单账户的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const accountAdd = params => apiService.post(api.ACCOUNT_ADD, params);
/**
 * 批量设置分单账户的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const accountModify = params => apiService.post(api.ACCOUNT_MODIFY, params);
/**
 * 批量开启/关闭分单账户的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const accountSwitch = params => apiService.post(api.ACCOUNT_SWITCH, params);
/**
 * 批量删除分单账户的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const accountDelete = params => apiService.post(api.ACCOUNT_DELETE, params);
/**
 * 分单账户设置界面-查看条件列表的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const conditionReview = params => apiService.post(api.CONDITION_REVIEW, params);
/**
 * 分单账户设置界面-查看三方出款商户列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const merchantReview = params => apiService.post(api.MERCHANT_REVIEW, params);
/**
 * 分单账户设置界面-查看三方出款商户列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const merchantList = params => apiService.post(api.MERCHANT_LIST, params);
/**
 * 出款专员点击通过/拒绝按钮、提现单状态改成处理中的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const seperatorOperation = params => apiService.post(api.SEPERATOR_OPERATION, params);


/**
 * 提现分单-列表查询
 * @param params
 * @returns {Promise<*>}
 *
 */
const withdrawSeperateList = params => apiService.post(api.SEPETRATE_LIST, params);

/**
 * 提现分单-批量回收检查
 * @param params
 * @returns {Promise<*>}
 *
 */
const batchRecoverCheck = params => apiService.post(api.BATCH_RECOVER_CHECK, params);

/**
 * 提现分单-批量回收
 * @param params
 * @returns {Promise<*>}
 *
 */
const batchRecoverInsure = params => apiService.post(api.BATCH_RECOVER_INSURE, params);

/**
 * 提现分单-批量分单检查
 * @param params
 * @returns {Promise<*>}
 *
 */
const batchSeperateCheck = params => apiService.post(api.BATCH_SEPERATE_CHECK, params);

/**
 * 提现分单-批量分单保存
 * @param params
 * @returns {Promise<*>}
 *
 */
const batchSeperateSave = params => apiService.post(api.BATCH_SEPERATE_SAVE, params);

/**
 * 提现分单-批量分单保存
 * @param params
 * @returns {Promise<*>}
 *
 */
const batchSeperateSelect = params => apiService.post(api.BATCH_SEPERATE_SELECT, params);
/**
 * 提现分单-批量分单保存
 * @param params
 * @returns {Promise<*>}
 *
 */
const accountBalance = params => apiService.post(api.ACCOUNT_BALANCE, params);
/**
 * 手动申请成功/失败的接口
 * @param params
 * @returns {Promise<*>}
 *
 */
const manualOperation = params => apiService.post(api.MANUAL_OPERTION, params);

/**
 * 查询三方状态
 * @param params
 * @returns {Promise<*>}
 *
 */
const checkInfoApi = params => apiService.post(api.CHECK_INFO, params);
/**
 * 置为失败
 * @param params
 * @returns {Promise<*>}
 *
 */
const markFail = params => apiService.post(api.MARK_FAIL_STATUS, params);
export {
  getWithdrawList,
  updateWithdrawStatus,
  getWithdrawDetail,
  getWithdrawShopList,
  getRechargeShopDetail,
  getWithdrawShopDetail,
  getWithdrawExceptionList,
  getWithdrawAuditList,
  updateWithdrawAuditStatus,
  getWithdrawConfigs,
  updateWithdrawConfigs,
  getWithdrawEscrows,
  getWithdrawEscrowDetail,
  editWithdrawEscrow,
  updateEcsrowsSort,
  updateWithdrawEscrowStatus,
  getWithdrawMerchantList,
  delWithdrawEscrow,
  getWithdrawBankList,
  returnWithdrawSave,
  getWithdrawReturnCreator,
  getWithdrawReturnApprover,
  updateWithdrawNormalStatus,
  withdrawForceSuccess, // 自动出款强制成功
  exportAutoRecord,
  withdrawNormalSetting,
  withdrawNormalSettingSave,
  withdrawRefuseReasonList,
  withdrawRefuseReasonSave,
  getWithdrawVipConfig,
  updateWithdrawVipConfig,
  getWithdrawAgencyConfigs,
  updateWithdrawAgencyConfigs,
  withdrawTimingConfig,
  withdrawTimingGet,
  withdrawConditionList,
  withdrawConditionDelete,
  withdrawConditionSave,
  withdrawConditionEdit,
  withdrawLevelList,
  withdrawAutoSave,
  withdrawAutoList,
  withdrawAutoUpdate,
  withdrawAutoDelete,
  withdrawAccountList,
  validateUser,
  accountAdd,
  accountModify,
  accountSwitch,
  accountDelete,
  conditionReview,
  merchantReview,
  withdrawSeperateList,
  merchantList,
  seperatorOperation,
  batchRecoverCheck,
  batchRecoverInsure,
  batchSeperateCheck,
  batchSeperateSave,
  batchSeperateSelect,
  accountBalance,
  manualOperation,
  checkInfoApi,
  markFail,
};
